-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor create_alert task #3759
Conversation
0235c6e
to
64fe5e1
Compare
engine/apps/alerts/models/alert.py
Outdated
if group_created: | ||
alert_group_escalation_snapshot_built.send(sender=cls.__class__, alert_group=alert.group) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Snapshot generation will happen synchronously in this task (previously it was done in distribute_alert)
TODO: check if it is not too heavy
if group_created or alert.group.pause_escalation: | ||
# Build escalation snapshot if needed and start escalation | ||
alert.group.start_escalation_if_needed(countdown=TASK_DELAY_SECONDS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start escalation here
(instead of checking if it is the first alert in distribute alert task https://github.com/grafana/oncall/pull/3759/files#diff-e0f70dd85cf6da1d72318bfb28759b3ebf069a28c16717ac233bf760df488a55R31)
else: | ||
transaction.on_commit( | ||
partial(tasks.distribute_alert.apply_async, (alert.pk,), countdown=TASK_DELAY_SECONDS) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this task anymore
TODO: don't forget to change alerts and dashboards
if not group.acknowledged and mark_as_acknowledged: | ||
group.acknowledge_by_source() | ||
|
||
# Create alert |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved alert creation and group creation together
TODO: consider adding transaction
# What this PR does This PR simplifies alert group/alert creation, so the alert created and escalation started in the same task. ## Which issue(s) this PR fixes ## Checklist - [ ] Unit, integration, and e2e (if applicable) tests updated - [ ] Documentation added (or `pr:no public docs` PR label added if not required) - [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required)
What this PR does
This PR simplifies alert group/alert creation, so the alert created and escalation started in the same task.
Which issue(s) this PR fixes
Checklist
pr:no public docs
PR label added if not required)CHANGELOG.md
updated (orpr:no changelog
PR label added if not required)